<html><head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"><title>NodeAnimation.pb</title></head>
<body bgcolor="#FFFFDF" link="#009999" vlink="#006666" alink="#006666">
<pre><font face="Courier New, Courier, mono"size="2"><font color="#006666">;
</font><font color="#006666">; ------------------------------------------------------------
</font><font color="#006666">;
</font><font color="#006666">;   PureBasic - NodeAnimation
</font><font color="#006666">;
</font><font color="#006666">;    (c) Fantaisie Software
</font><font color="#006666">;
</font><font color="#006666">; ------------------------------------------------------------
</font><font color="#006666">;
</font><font color="#006666">;An example of using AnimationTracks To make a node smoothly 
</font><font color="#006666">;follow a predefined path With spline interpolation.

</font><b><font color="#006666">IncludeFile</font></b> <font color="#924B72">#PB_Compiler_Home</font> + "examples/3d/Screen3DRequester.pb"

<b><font color="#006666">Declare</font></b> <font color="#006666">AddPath</font>(NodeAnimation)
<b><font color="#006666">Define</font></b>.f Duration = 10000, Time = Duration / 4

<b><font color="#006666">If</font></b> <font color="#006666">InitEngine3D</font>()
  
<font color="#006666">  InitSprite</font>()
<font color="#006666">  InitKeyboard</font>()
<font color="#006666">  InitMouse</font>()
  
  <b><font color="#006666">If</font></b> <font color="#006666">Screen3DRequester</font>()
<font color="#006666">    Add3DArchive</font>(<font color="#924B72">#PB_Compiler_Home</font> + "examples/3d/Data"                , <font color="#924B72">#PB_3DArchive_FileSystem</font>)    
<font color="#006666">    Add3DArchive</font>(<font color="#924B72">#PB_Compiler_Home</font> + "examples/3d/Data/Textures"        , <font color="#924B72">#PB_3DArchive_FileSystem</font>)
<font color="#006666">    Add3DArchive</font>(<font color="#924B72">#PB_Compiler_Home</font> + "examples/3d/Data/Models"          , <font color="#924B72">#PB_3DArchive_FileSystem</font>)
<font color="#006666">    Add3DArchive</font>(<font color="#924B72">#PB_Compiler_Home</font> + "examples/3d/Data/Scripts"         , <font color="#924B72">#PB_3DArchive_FileSystem</font>)
<font color="#006666">    Add3DArchive</font>(<font color="#924B72">#PB_Compiler_Home</font> + "examples/3d/Data/Packs/desert.zip", <font color="#924B72">#PB_3DArchive_Zip</font>)
<font color="#006666">    Parse3DScripts</font>()
    
    <font color="#006666">;- Barrel
</font><font color="#006666">    CreateEntity</font>(1,<font color="#006666"> LoadMesh</font>(1, "Barrel.mesh"), <font color="#924B72">#PB_Material_None</font>)
<font color="#006666">    ScaleEntity</font>(1, 9, 9, 9)
    
    <font color="#006666">;- Camera
</font><font color="#006666">    CreateCamera</font>(0, 0, 0, 100, 100)
    
    <font color="#006666">;- Node
</font><font color="#006666">    CreateNode</font>(0)
<font color="#006666">    AttachNodeObject</font>(0,<font color="#006666"> CameraID</font>(0))
    
    <font color="#006666">;- Light
</font><font color="#006666">    AmbientColor</font>(<font color="#006666">RGB</font>(75, 75, 75))
<font color="#006666">    CreateLight</font>(0,<font color="#006666"> RGB</font>(235, 253, 126), -750, 750, -750)
    
    <font color="#006666">;- SkyBox
</font><font color="#006666">    SkyBox</font>("desert07.jpg")
    
    <font color="#006666">;- NodeAnimation 
</font>    NodeAnimation =<font color="#006666"> CreateNodeAnimation</font>(<font color="#924B72">#PB_Any</font>,<font color="#006666"> NodeID</font>(0), Duration, <font color="#924B72">#PB_NodeAnimation_Spline</font>, <font color="#924B72">#PB_NodeAnimation_LinearRotation</font>)
        
<font color="#006666">    CreateNodeAnimationKeyFrame</font>(NodeAnimation, Time * 0,  200,   0,    0)<font color="#006666">; key 0
</font><font color="#006666">    CreateNodeAnimationKeyFrame</font>(NodeAnimation, Time * 1,    0, -50,  100)<font color="#006666">; key 1
</font><font color="#006666">    CreateNodeAnimationKeyFrame</font>(NodeAnimation, Time * 2, -500, 100,    0)<font color="#006666">; key 2
</font><font color="#006666">    CreateNodeAnimationKeyFrame</font>(NodeAnimation, Time * 3,    0, 200, -300)<font color="#006666">; key 3
</font><font color="#006666">    CreateNodeAnimationKeyFrame</font>(NodeAnimation, Time * 4,  200,   0,    0)<font color="#006666">; key 4
</font>    
<font color="#006666">    StartNodeAnimation</font>(NodeAnimation)
    
    <b><font color="#006666">Repeat</font></b>
<font color="#006666">      Screen3DEvents</font>()
      
<font color="#006666">      ExamineKeyboard</font>()
<font color="#006666">      AddNodeAnimationTime</font>(NodeAnimation, TimeSinceLastFrame)
<font color="#006666">      CameraLookAt</font>(0,<font color="#006666"> EntityX</font>(1),<font color="#006666"> EntityY</font>(1),<font color="#006666"> EntityZ</font>(1))
      
      TimeSinceLastFrame =<font color="#006666"> RenderWorld</font>()
<font color="#006666">      FlipBuffers</font>()
      
    <b><font color="#006666">Until</font></b> <font color="#006666">KeyboardPushed</font>(<font color="#924B72">#PB_Key_Escape</font>)   
    
    <b><font color="#006666">End</font></b> 
    
  <b><font color="#006666">EndIf</font></b> 
<b><font color="#006666">Else</font></b>
<font color="#006666">  MessageRequester</font>("Error","Can't initialize engine3D")
<b><font color="#006666">EndIf</font></b> 
</font></pre>
</body></html>
